<?php echo $this->Html->css(array('konkurs'),null,array('inline'=>false));?>
<center><?php echo $this->Html->image(Configure::read('competition_domain').'/files/konkurs.kawalavazza.com/krok2.jpg')?></center>
<table style="width: 100%; margin: 0px; padding: 0px;">
	
	<tr>
		<td valign="top" width="30%" style="border-bottom: none;">
			<h4 class="info">Blog, forum, strona www</h3>
			<div style="padding-left: 10px;">Wklej kolejno linki do stron internetowych, na których zamieściłeś/aś odpowiedź na pytanie konkursowe.</div> 
		</td>
		<td width="40%" style="padding-top: 20px; padding-bottom: 20px; border-bottom: none;" >

			<?php echo $this->Form->create('CompetitionUrl',array('url'=>Router::url( $this->here, true ),'name'=>'CompetitionUrlShareForm'));?>		
			<?php	
				echo $this->Form->hidden('competition_post_id',array('value'=>$this->request->data['CompetitionPost']['id']));	// jesli zdefiniowane i wartosc 1 dodaj url i wroc do tej strony		
				echo $this->Form->input('CompetitionUrl.url',array('label'=>'Link','after'=>__('przykład: <span style="color:#aa0000;">http://kawalavazza.com/pl/i/konkurs/9</span><br/>tutaj podaj link do strony www na której zapisałeś odpowiedź'),'class'=>'users_urls'));				
			?>
			<?php echo $this->Form->end();?>
		</td>
		<td width="20%" style="padding-top: 26px; padding-bottom: 20px; border-bottom: none;">
			<div class="submit">
				<label for="CompetitionSubmitUrl">&nbsp;</label>
				<input type="submit" value="Zapisz link" id="CompetitionSubmitUrl" onclick="document.CompetitionUrlShareForm.submit(); event.returnValue = false; return false;"/>
				<br/>
				<span>po zapisaniu dodaj kolejne linki
			</div>		
		</td>
		<td width="10%" rowspan="4">
			<?php echo $this->Html->image('/files/konkurs.kawalavazza.com/nagrody.jpg')?>
		</td>
	</tr>
	<tr>
		<td valign="top">
			<div style="padding-left: 10px;">dodane linki: <?php if(isset($this->request->data['CompetitionUrl']) && empty($this->request->data['CompetitionUrl'])){?> nie dodano linku<?php }?></div>
		</td>
		<td colspan="2">
			<?php if(isset($this->request->data['CompetitionUrl']) && !empty($this->request->data['CompetitionUrl'])){?>
				<?php foreach ($this->request->data['CompetitionUrl'] as $key => $url) {
					echo $this->Html->link($url['url'],$url['url']).'<br/>';
				}?>
			<?php }?>
		</td>
	</tr>
	
	<tr>
		<td valign="top">
			<h4 class="info">Facebook, Google+, Twitter</h3>
			<div style="padding-left: 10px;">
			Skopiuj odpowiedź i poleć ją w formie komentarza na własnym profilu  Facebooka, Google+ lub Twittera
			</div>					
		</td>
		<td>

			<?php 
				echo $this->Form->create('CompetitionPost',array('url'=>Router::url( $this->here, true )));
				echo $this->Form->input('content',array('label'=>'Twoja odpowiedź','readonly'=>true,'style'=>'height:130px; font-size:11px;','after'=>'skopiuj powyższy tekst i wklej do Facebook, Google +, Twitter'));
				echo $this->Form->end();
			?>
		
		</td>
		<td style="padding-top: 0px;">
			<h4 class="info">Poleć</h3>
			<div style="margin-bottom: 20px; margin-top: 10px">
			
				<div id="fb-root"></div>
				<p>
					<a onclick="postToFeed(); return false;" id="FacebookFeed"><?php echo $this->Html->image(Configure::read('competition_domain').'/files/konkurs.kawalavazza.com/facebook.png')?></a> 
					<a href="#" style="display: none;"> V </a>
				</p>
				<script src='http://connect.facebook.net/pl_PL/all.js'></script>
				<script>
					FB.init({appId: "432513693472330", status: true, cookie: true});
				      function postToFeed() {
				
				          // calling the API ...
				          var obj = {
				            method: 'feed',
				            link: '<?php echo $this->request->data['CompetitionPost']['product_url'];?>'
				          };
				
				          function callback(response) {
				           //document.getElementById('CompetitionPostContent').innerHTML = "Post ID: " + response['post_id'];
					       //alert('result:' + response['post_id']);
					        if(response['post_id'] != ''){
								$.ajax(
									{
										async:true, 
										dataType:"html", 
										success: function (data, textStatus) 
											{
												if(data == '1') $('#FacebookFeed').attr('onclick','#');
											},
										url:"http:\/\/panel.seosolution.pl\/competitions\/share\/<?php echo $this->request->data['CompetitionPost']['id'];?>/s:f"
									});
									return false;
								
					        }
				          }
				
				          FB.ui(obj, callback);
				       }
			       </script>				   
	
			</div>
			
			<div style=" margin-bottom: 20px;">
			
				<!-- Place this tag where you want the +1 button to render. -->
				<div class="g-plusone" data-annotation="none" data-callback="callback_google" data-href="<?php echo $this->request->data['CompetitionPost']['product_url'];?>"></div>
				
				<!-- Place this tag after the last +1 button tag. -->
				<script type="text/javascript">
				  window.___gcfg = {lang: 'pl'};
				
				  (function() {
				    var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
				    po.src = 'https://apis.google.com/js/plusone.js';
				    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
				  })();


		          function callback_google(plusone) {
		        	  		//window.alert('+1 Triggered, State=' + plusone.state);
							$.ajax(
								{
									async:true, 
									dataType:"html", 
									success: function (data, textStatus) 
										{
											// disable button

										},
									url:"http:\/\/panel.seosolution.pl\/competitions\/share\/<?php echo $this->request->data['CompetitionPost']['id'];?>/s:g/state:"+plusone.state
								});
								return false;
							
			          }
				</script>
  

			</div>
			<div style="">
				<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php echo $this->request->data['CompetitionPost']['product_url'];?>" data-text="" data-via="" data-lang="en" data-size="large" data-count="none" data-dnt="true">Tweetnij</a>
				<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
				<script>
					$.getScript("http://platform.twitter.com/widgets.js", function(){
					   function handleTweetEvent(event){
					     if (event) {
					       alert("This is a callback from a tweet");
				    		 $.ajax(
										{
											async:true, 
											dataType:"html", 
											success: function (data, textStatus) 
												{
													// disable button
		
												},
											url:"http:\/\/panel.seosolution.pl\/competitions\/share\/<?php echo $this->request->data['CompetitionPost']['id'];?>/s:t"
										});
										return false;
					     }
					   }
					   twttr.events.bind('tweet', handleTweetEvent);        
					 });
				</script>
			</div>				
		</td>

	</tr>	
	<tr>
		<td valign="middle">
			<a href="http://kawalavazza.com/pl/i/konkurs/9" target="_blank">
				<?php echo $this->Html->image(Configure::read('competition_domain').'/files/konkurs.kawalavazza.com/logo.jpg',array('alt'=>"logo",'align'=>"middle"))?>
			</a>
		</td>
		<td style="text-align: right; vertical-align: middle;">
			<div class="text">Jelśli opublikowałeś już swoją odpowiedź kliknij przycisk zakończ</div>
		</td>
		<td valign="middle" style="text-align: left; vertical-align: middle;">
			<?php 
				echo $this->Form->create('CompetitionPost',array('url'=>array('plugin'=>false,'controller'=>'competitions','action'=>'end',$this->request->data['CompetitionPost']['id'])));
				echo $this->Form->hidden('CompetitionPost.koniec',array('value'=>'1'));			
				echo $this->Form->end(__('Zakończ'));
			?>	
		</td>
	</tr>
</table>